package com.example.property.mapper;

import com.example.property.pojo.Floor;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface FloorMapper {
    @Select("select floor_id,floor_number from floor " +
            "where belong_building = #{id}")
    List<Floor> floorsOfBuilding(Integer id);

    @Insert("<script>insert into floor (floor_id, belong_building, floor_number, room_number) values " +
            "<foreach collection=\"list\" index=\"i\" item=\"item\" separator=\",\">" +
            "( #{item.floorId}, #{item.belongBuilding}, #{item.floorNumber}, #{item.roomNumber} ) </foreach></script>")
    @Options(useGeneratedKeys = true, keyProperty = "floorId", keyColumn = "floor_id")
    int insertFloors(List<Floor> floors);




}
